<template>
	<view class="page">
		<view class="box">
			<view class="box-left">
				手机号
			</view>
			<view class="box-right">
				<input placeholder="请输入手机号" type="text" v-model="phone" />
			</view>
		</view>
		<view class="shape_btn" @click="edit">
			修改
		</view>
	</view>
</template>

<script>
	const api = require('../../config/api');
	const util = require('../../utils/util');
	export default {
		data() {
			return {
				phone:'',
				id:'',
			}
		},
		onLoad(o) {
			this.id = o.id
			this.phone = o.phone
		
		},
		onShow() {
		},
		methods: {
			edit(){
				if(!this.phone){
				uni.showToast({
					title: '请填写手机号',
					icon: 'none'
				});
					return;
				}else{
					this.editphone();
				}
			},
			async editphone() {
				const res = await util.request(
					api.editphoneUrl +'/'+this.id +'/'+this.phone, {},
					'POST'
				);
				// console.log(res);
				if (res.code !== 0) {
					uni.showToast({
						title: res.msg,
						icon: "none"
					})

				} else {
					uni.showToast({
						title: '修改成功',
						icon: "none"
					})
					setTimeout(()=>{
						uni.navigateBack()
					},1000)
				}
			},
		}
	}
</script>
<style>
	page{
	
		height: 100%;
		background-color: #F7F7F7;
	}
</style>
<style lang="scss" scoped>
	.page{
	
		height: 100%;
		background-color: #F7F7F7;
	}
	.box{
		margin-top: 6px;
		background-color: #fff;
		height: 45px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0px 15px;
	}
	.box-left{
		font-size: 15px;
		color: #949494;
	}
	.box-right{
		margin-left: 15px;
		flex: 1;
		text-align: right;
	}
	.shape_btn{
		height: 44px;
		margin: 20px 30px;
		line-height: 44px;
		text-align: center;
		font-size: 17px;
		color: #fff;
		background-color: #6A9FFB;
		border-radius: 5px;
	}
</style>